package com.cy.springcloud.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: 第一个controlller
 * @ClassName: WebController
 * @Author: chenyu
 * @Date: 2025/1/3 14:57
 */
@RestController
public class WebController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping(value = "/web/hello", method = RequestMethod.GET)
    public String hello() {
        //调用SpringCloud服务提供者提供的服务
        //return restTemplate.getForEntity("http://localhost:8080/hello", String.class).getBody();
        return restTemplate.getForEntity("http://01-springcloud-service-provider/hello", String.class).getBody();
    }
}
